package com.mall.cart.server.controller;


import com.mall.cart.server.service.ICartItemService;
import com.mall.cart.server.vo.CartItemVo;
import com.mall.cart.server.vo.CartRequest;
import com.mall.cart.server.vo.CartVo;
import com.mall.common.core.domain.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/cart")

public class CartItemController {

    @Resource
    private ICartItemService iCartItemService;

    /**
     * 添加购物车
     * @return
     */
    @PostMapping("/add")
    public void addCart(@RequestBody CartRequest cartRequest){
        iCartItemService.addCartItem(cartRequest);
    }
    /**
     * 删除购物车
     */
    @DeleteMapping("deleteCartItem/{skuIds}")
    public void deleteCartItem(@PathVariable String skuIds){
        iCartItemService.deleteCartItem(skuIds);
    }

    /**
     * 购物车列表
     */
    @GetMapping("/findCartList")
    public Result<List<CartItemVo>> cartVoList(){
        List<CartItemVo> cartItemVos = iCartItemService.cartVoList();
        return Result.success(cartItemVos);
    }

}
